package com.logis.ryanrqwork.ui.activity;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;

import com.logis.ryanrqwork.MainActivity;
import com.logis.ryanrqwork.R;
import com.logis.ryanrqwork.utils.SharedUtil;

public class SplashActivity extends AppCompatActivity {
    Handler handler = new Handler() {
        @Override
        public void handleMessage(@NonNull Message msg) {
            super.handleMessage(msg);
            if (TextUtils.isEmpty(SharedUtil.getInstance(SplashActivity.this).getSP(SharedUtil.SHARED_USER_ID))) {
                startActivity(new Intent(SplashActivity.this, LoginActivity.class));
            } else {
                startActivity(new Intent(SplashActivity.this, MainActivity.class));
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        handler.sendEmptyMessageDelayed(0, 1000);
    }
}
